package ordinary;

import java.util.Comparator;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Wukong
 * Date: 2022-06-03
 * Time: 14:47
 */
public class GenericityTwo<T extends Comparable<T>> {
    public  T Compare(T[]arry){
        T max=arry[0];
        for (int i = 0; i <arry.length; i++) {
            if (arry[i].compareTo(max)>0){
                max=arry[i];
            }
        }
        return max;

    }

    public static void main(String[] args) {
        GenericityTwo<Integer> genericity=new GenericityTwo<>();
        Integer[]arry={20,21,22,23};
        int ret=genericity.Compare(arry);
        System.out.println(ret);
    }
}
 class Univversal<T extends Comparable<T>>{
    public static <T extends Comparable<T>> T compare(T[]arry){
        T max=arry[0];
        for (int i = 0; i <arry.length; i++) {
            if (arry[i].compareTo(max)>0){
                max=arry[i];
            }
        }
        return max;
    }

    public static void main(String[] args) {
       Integer[]arry={20,21,22,23};
        int ret=Univversal.<Integer>compare(arry);
        System.out.println(ret);
    }

}
